#pragma once 
#include <pthread.h>

class Mutex
{
private:
    pthread_mutex_t* pmtx_;
public:
    Mutex(pthread_mutex_t* pmtx):pmtx_(pmtx)
    { }

    void lock()
    {
        pthread_mutex_lock(pmtx_);
    }

    void unlock()
    {
        pthread_mutex_unlock(pmtx_);
    }

    ~Mutex()
    { }
};

class lockGuard
{
private:
    /* data */
    Mutex _mtx;
public:
    lockGuard(pthread_mutex_t* pmtx);
    ~lockGuard();
};

lockGuard::lockGuard(pthread_mutex_t* pmtx):_mtx(pmtx)
{
    _mtx.lock();
}

lockGuard::~lockGuard()
{
    _mtx.unlock();
}

